#!/bin/bash
echo "------ 切换到代码区 ------"
echo "cd /root/.jenkins/workspace/jenkins-cicd-vue"
cd /root/.jenkins/workspace/jenkins-cicd-vue

echo "------ 下载依赖 ------"
echo "npm install"
npm install

echo "------ build项目代码 ------"
echo "npm run build"
npm run build

echo "------ 删除nginx/html/dist目录 ------"
echo "rm -rf /home/softwares/nginx1.25.3/nginx/html/dist/"
rm -rf /home/softwares/nginx1.25.3/nginx/html/dist/

echo "------ 把打包好的项目复制到nginx/html/dist目录 ------"
echo "cp -r /root/.jenkins/workspace/jenkins-cicd-vue/dist/ /home/softwares/nginx1.25.3/nginx/html"
cp -r /root/.jenkins/workspace/jenkins-cicd-vue/dist/ /home/softwares/nginx1.25.3/nginx/html

echo "------ nginx重新加载发布后的资源 ------"
echo "cd /home/softwares/nginx1.25.3/nginx/sbin"
echo "./nginx -s stop"
echo "./nginx"
cd /home/softwares/nginx1.25.3/nginx/sbin
./nginx -s stop
./nginx
